

#include <bits/stdc++.h>
using namespace std;

int ifOK(int x)
{
    if (x == 1)
    {
        return 0;
    }
    if (x == 2)
    {
        return 1;
    }
    if (x % 2 == 0)
    {
        return 0;
    }
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return 0;
        }
    }
    return 1;
}
int main(void)
{

    int start;
    int end;

    cin >> start >> end;
    if (start > end)
    {
        int tmp = start;
        start = end;
        end = tmp;
    }
    long sum = 0;
    for (int i = start; i <= end; i++)
    {
        if (ifOK(i))
            sum++;
    }
    cout << sum;
}